//
//  RegiestAndLoginViewController.m
//  Example
//
//  Created by test on 2017/10/27.
//  Copyright © 2017年 Buge. All rights reserved.
//

#import "RegiestAndLoginViewController.h"
#import "JavaBaas.h"

@interface RegiestAndLoginViewController ()

@end

@implementation RegiestAndLoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
}



//注册
- (IBAction)signUp:(UIButton *)sender {
    _alertTextView.text = @"";
    if (_usernameTextField.text.length == 0 || _passwordTextField.text.length == 0) {
        _alertTextView.text = @"请输入用户名和密码。";
        return;
    }
    
    JBUser *user = [JBUser user];
    user.username = _usernameTextField.text;
    user.password = _passwordTextField.text;
    //    异步
    [user signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
        if (!error) {
            _alertTextView.text = @"注册成功";
        }else {
            _alertTextView.text = [NSString stringWithFormat:@"注册失败：%@", [error domain]];
        }
    }];
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
@end
